var $ = require('./util.js'); 
var CryptoJS = require('./crypto-js.js')
// 签名密钥
const SECRET_KEY = "method-url-body-timestamp-nonce-123456789-abcdefg-@#$%&*.?";
// 生成随机字符串
function generateNonce() {
  return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
}
// 递归排序函数 
function sortObject(obj) {
  if (obj === null || typeof obj !== "object") {
      return obj; // 如果是 null 或非对象，直接返回
  }

  if (Array.isArray(obj)) {
      // 对数组中的每个元素递归排序
      return obj.map(sortObject);
  }

  // 对对象的键名排序并递归处理值
  return Object.keys(obj)
      .sort()
      .reduce((sorted, key) => {
          sorted[key] = sortObject(obj[key]);
          return sorted;
      }, {});
}
import {config} from './config.js'
var imageUrl="https://s.ruidcn.cn"






module.exports = { 
  url: config.baseURL,
  imageUrl: imageUrl,
  main: { 
    code: config.baseURL+ '/code', // 验证码接口
    refreshToken: config.baseURL+ '/mobileSafeMoudle/miniProgram/refreshToken', // 接受app跳转的参数请求
    login: config.baseURL+ '/auth/login', // 登陆接口
    userInfo: config.baseURL+ '/system/user/profile', // 用户信息
    checkUserLogin :config.baseURL +"/index/login/checkUserLogin",//检查密码是否过期
    // upload: config.baseURL + '/index.php/common.upload/upload', // 上传图片
    upload: config.baseURL + '/common/image/upload', // 上传图片
    getYxList: config.baseURL + '/mobileSafeMoudle/index/station/getYxList', // 遥信列表
    unbalance:config.baseURL+'/mobileSafeMoudle/index/station/unbalance',//三项不平衡list  unbalance
    getIndexStatistical: config.baseURL + '/index/station/getIndexStatistical', // 获取统计数据【主页】（负荷）
    selectTree:config.baseURL+'/mobileSafeMoudle/choose/selectProvinceStationTree',//wave tree
    index: config.baseURL + '/mobileSafeMoudle/count/index', // 首页接口
    total: config.baseURL + '/mobileSafeMoudle/count/total', // 二级页面统计数据 
    selectCompany: config.baseURL + '/mobileSafeMoudle/choose/selectCompany', // 公司列表
    selectEnterprise: config.baseURL + '/mobileSafeMoudle/choose/selectEnterprise', // 企业列表
    selectStation1: config.baseURL + '/mobileSafeMoudle/choose/selectStation', // 站房列表
    getRepairer: config.baseURL + '/mobileSafeMoudle/choose/getRepairer', // 获取抢修负责人、 抢修人员 、缺陷发现人
    selectYcxlm: config.baseURL + '/mobileSafeMoudle/choose/selectYcxlm', // 根据站房获取设备列表
    getDefectStandard: config.baseURL + '/mobileSafeMoudle/choose/defectStandard', // 获取缺陷标准和性质
    selected: config.baseURL + '/mobileSafeMoudle/choose/selected', // 企业和站房列表接口
    selectSchoolTree: config.baseURL +"/mobileSafeMoudle/choose/selectSchoolTree",//宿舍用电 树形接口
    selectSchoolTree: config.baseURL +"/mobileSafeMoudle/choose/selectSchoolTree",
    //最新接口
    selectProject:config.baseURL+'/mobileSafeMoudle/ticket/deviceTree/projectList',//项目
    selectStation:config.baseURL+'/mobileSafeMoudle/ticket/deviceTree/stationList',//厂站
    selectDevice:config.baseURL+'/mobileSafeMoudle/ticket/deviceTree/equipList',//设备
    selectSwitch:config.baseURL+'/mobileSafeMoudle/ticket/deviceTree/switchList',//开关
    selectAreaList:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/maintenanceAreaList',//选择片区
    selectWorkTeam: config.baseURL + '/mobileSafeMoudle/ticket/ticketWork/teamList', // 获取两票班组列表
    userSignature: config.baseURL + '/mobileSafeMoudle/ticket/role/currentUserSignature', // 当前用户签名
    userRoleList: config.baseURL + '/mobileSafeMoudle/ticket/role/getCurrentUserRoleList', // 当前用户具有所有的角色
    userTicketRoleList: config.baseURL + '/mobileSafeMoudle/ticket/role/getCurrentUserTicketRoleList', // 当前用户在票中具有的角色
    uploadWorkImg: config.baseURL + '/mobileSafeMoudle/ticket/ticketWork/upload/image', // 上传工作票图片
    uploadOptImg: config.baseURL + '/mobileSafeMoudle/ticket/ticketOperation/upload/image', // 上传操作票图片
  },
  auth:{
    findDeptIdByEquip:config.baseURL + '/mobileSafeMoudle/choose/findDeptIdByEquip', // 查找设备  设备树id
    findDeptIdBystation:config.baseURL + '/mobileSafeMoudle/choose/findDeptIdByStation', // 查找厂站设备树id
    findTypeByequip:config.baseURL+"/mobileSafeMoudle/choose/findTypeByEquip"
  },
  warningManage:{ // 告警
    getNewStatistical: config.baseURL + '/mobileSafeMoudle/index/station/getNewStatistical', // 获取统计数据【二级分类】
    getRedisStatistical: config.baseURL + '/mobileSafeMoudle/index/station/getRedisStatistical', // 获取统计数据-当前数据【二级分类】
    setRushRepair: config.baseURL + '/mobileSafeMoudle/matain/rush/add', // 告警转抢修处理 
    setDefect: config.baseURL + '/mobileSafeMoudle/matain/defect/save', // 告警转缺陷处理
    setUpdate: config.baseURL + '/mobileSafeMoudle/matain/event/ignore', // 告警忽略处理
    getList: config.baseURL + '/mobileSafeMoudle/matain/event/list', // 告警列表
  },
  pollingManage:{ //巡检
    defectRecord: config.baseURL + '/index.php/index.patrolplan/defectRecord', // 缺陷记录
    update: config.baseURL + '/mobileSafeMoudle/matain/patrolplan/update', // 执行巡检任务
    updateInfo: config.baseURL + '/mobileSafeMoudle/matain/patrolplan/update', // 巡检更新提交 
    setDefectBypatrolplan: config.baseURL + '/mobileSafeMoudle/matain/defect/saven', // 巡检登记缺陷 
    info: config.baseURL + '/mobileSafeMoudle/matain/patrolplan/info', // 巡检列表 
    record: config.baseURL + '/mobileSafeMoudle/matain/patrolplan/record', // 巡检记录
    recordFile: config.baseURL + '/mobileSafeMoudle/matain/patrolplan/recordFile', // 巡检记录 
    getList: config.baseURL + '/mobileSafeMoudle/matain/patrolplan/list', // 巡检列表
  },

  repairsManage:{ // 报修
    infoByLinkticket: config.baseURL + '/mobileSafeMoudle/matain/rush/infoByLinkticket', // 关联单
    setDefectByrepair: config.baseURL + '/index.php/index.repair/setDefectByrepair', // 缺陷
    setRushRepairByrepair: config.baseURL + '/mobileSafeMoudle/matain/rush/add', // 转抢修
    setZuoFei: config.baseURL + '/mobileSafeMoudle/matain/report/update', // 作废
    update: config.baseURL + '/mobileSafeMoudle/matain/report/update', // 更新报修内容
    setCheckByrepair: config.baseURL+'/mobileSafeMoudle/matain/check/add',//转检修
    getList: config.baseURL + '/mobileSafeMoudle/matain/report/list', // 报修列表
    info: config.baseURL + '/mobileSafeMoudle/matain/report/info', // 报修详情
    repairAdd: config.baseURL + '/mobileSafeMoudle/matain/report/add', // 报修派单
  },
  
  robManage: { // 抢修
    getList: config.baseURL + '/mobileSafeMoudle/matain/rush/list', // 抢修列表
    info: config.baseURL + '/mobileSafeMoudle/matain/rush/info', // 详情
    add: config.baseURL + '/mobileSafeMoudle/matain/rush/add', // 新增加
    update: config.baseURL + '/mobileSafeMoudle/matain/rush/updateStatus', // 抢修回执单
    updateStatus: config.baseURL + '/mobileSafeMoudle/matain/rush/updateStatus', // 抢修回执单
    setDefectByrob: config.baseURL + '/index.php/index.rush/setDefectByrob' // 登记缺陷
  },
  defect: { // 缺陷  
    update: config.baseURL + '/mobileSafeMoudle/matain/defect/save', // 缺陷更新和添加
    info: config.baseURL + '/mobileSafeMoudle/matain/defect/info' ,// 缺陷详情
    setZuoFei:config.baseURL + '/mobileSafeMoudle/matain/defect/save',//作废
    cancelZuoFei:config.baseURL + '/mobileSafeMoudle/matain/defect/save',//取消作废
    finishDefect:config.baseURL + '/mobileSafeMoudle/matain/defect/save',//缺陷完成
    setCheckBydefect: config.baseURL + '/mobileSafeMoudle/matain/check/add', //，转检修
    setRushByDefect:config.baseURL + '/mobileSafeMoudle/matain/rush/add',//转抢修
    getList1: config.baseURL + '/mobileSafeMoudle/matain/defect/list', // 缺陷列表  
  },
  checkManage: { // 检修
    getList: config.baseURL + '/mobileSafeMoudle/matain/check/list', // 检修列表
    info: config.baseURL + '/mobileSafeMoudle/matain/check/info', // 检修详情
    update: config.baseURL + '/mobileSafeMoudle/matain/check/update', // 检修保存 
    setDefectBycheck: config.baseURL + '/mobileSafeMoudle/matain/defect/save', // 检修转缺陷
  },
  lockManage:{
    lockSearch:config.baseURL +'/mobileSafeMoudle/lock/search',//锁具搜索
    companyList:config.baseURL +'/mobileSafeMoudle/lock/companyList',//企业列表
    projectList:config.baseURL +'/mobileSafeMoudle/lock/projectList',//项目列表
    stationList:config.baseURL +'/mobileSafeMoudle/lock/stationList',//场站列表
    areaList:config.baseURL +'/mobileSafeMoudle/lock/areaList',//区域列表
    lockList:config.baseURL +'/mobileSafeMoudle/lock/lockList',//锁具列表
    createCompany:config.baseURL +'/mobileSafeMoudle/lock/createCompanyNode',//创建企业
    createProject:config.baseURL +'/mobileSafeMoudle/lock/createProjectNode',//创建项目
    createStation:config.baseURL +'/mobileSafeMoudle/lock/createStationNode',//创建场站
    createArea:config.baseURL +'/mobileSafeMoudle/lock/createAreaNode',//创建区域
    createLockAdd:config.baseURL +'/mobileSafeMoudle/lock/createLockNode',//创建锁具
    lockAdd:config.baseURL +'/mobileSafeMoudle/lock/lockAdd',//新增锁具
    lockKeys:config.baseURL +'/mobileSafeMoudle/lock/lockKeys',//获取锁具相关密钥
    applyLockOpen:config.baseURL +'/mobileSafeMoudle/lock/applyLockTemporaryAuth',//申请临时开锁权限
    applyLockAuthList:config.baseURL +'/mobileSafeMoudle/lock/applyLockAuthList',//查看本人申请的开锁权限审批情况
    logAdd:config.baseURL +'/mobileSafeMoudle/lock/logAdd',//开锁关锁日志记录
  },
  workTicket:{
    workTickList:config.baseURL +'/mobileSafeMoudle/ticket/ticketWork/list',//两票列表
    ticketCount:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/count',
    addTempTeam:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/addTempTeam',//创建临时团队
    requestTicketNumber:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/requestTicketNumber',//申请票号
    workTickInfo:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/info/',
    workIssuerList:config.baseURL+'/mobileSafeMoudle/ticket/role/workIssuerList',
    externalIssuerList:config.baseURL+'/mobileSafeMoudle/ticket/role/externalIssuerList',
    measureTypeList:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/deviceMeasureTypeList',//安措类型
    safetyMeasures:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/safetyMeasuresLibrary',//安措步骤
    addTicketWork:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/addTicketWork',//添加工作票--先添加再生成安措后再修改在提交
    modifyTicketStatus:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/workLeaderModifyTicketWorkStatus',//添加工作票--先添加再生成安措后再修改在提交
    editTicketWork:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/editTicketWork',//修改工作票--先修改再提交
    safetyMeasuresSave:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/safetyMeasuresLibrarySave',//保存安措
    submitTicketWork:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/submitTicketWork',//提交工作票
    designatedIssuer:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/designatedIssuer',//指定签发人
    safetyRiskCard:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/safetyRiskControlCard',//生成安全风险卡
    addSafetyRiskCard:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/safetyRiskControlCardSave',//添加安全风险卡
    workLeaderList:config.baseURL+'/mobileSafeMoudle/ticket/role/workLeaderList',//工作负责人列表
    workLeaderChange:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/workLeaderChange',//工作负责人变动
    workLeaderChangeXKR:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/workLeaderChangeWorkPermitterConfirm',//工作许可人确认更换工作负责人
    workLeaderChangeQFR:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/workLederChangeWorkIssuerConfirm',//工作签发人确认更换工作负责人
    teamMemberChange:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/teamMemberChange',//工作班组成员变动
    signUpload:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/upload/signature',//工作票签名
    tickeWorkDelay:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/tickeWorkDelay',//工作票延期
    workDelayDutyConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/ticketWorkDelayDutyConfirm',//值班人员确认延期
    workDelayPermitIssuerConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/ticketWorkDelayPermitIssuerConfirm',//签发人确认延期

    issuerExame:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/issueTicketWorkForIssuer',//签发人审核
    externalIssuerExame:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/issueTicketWorkForExternalIssuer',//外部签发人审核
    dutyCenterExame:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/dutyCenterDutyReceiveTicketWork',//监控中心值班人审核
    permiterExame:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/permitTicketWork',//许可人审核
    riskMemberConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/safetyRiskControlCardWorkMemberConfirm',//风险控制卡审核-工作班组成员确认
    riskLeaderConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/safetyRiskControlCardWorkLeaderConfirm',//风险控制卡审核-工作负责人确认
    permitIssuerMeasuresConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/safetyMeasuresTasksAndWorkStartWorkPermitIssuerConfirm',//工作许可人确认安全措施执行和许可开始工作
    teamMemberMeasuresConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/teamMemberWorkAndSafetyMeasuresConfirm',//工作班组成员确定安全措施
    workStartWorkLeaderConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/workStartWorkLeaderConfirm',//工作负责人确认工作开始
    submitWorkDailyLog:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/submitWorkDailyLog',//工作负责人提交每日开工收工记录
    dailyLogPermitIssuerConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/workDailyLogPermitIssuerConfirm',//工作许可人审核每日开工收工记录
    workEndRemark:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/ticketWorkEndRemark',//工作负责人填写终结备注
    workEndWorkLeaderConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/ticketWorkEndWorkLeaderConfirm',//工作负责人确认工作票终结
    workEndWorkPermitIssuerConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketWork/ticketWorkEndWorkPermitIssuerConfirm',//许可人确认工作票终结
  },
  operateTicket:{
    operateTickList:config.baseURL +'/mobileSafeMoudle/ticket/ticketOperation/list',//操作票列表
    operateTickInfo:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/info/',
    ticketCount:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/count',
    receiveIssuer:config.baseURL+'/mobileSafeMoudle/ticket/role/isReceiveIssuer',//受领人
    operationList:config.baseURL+'/mobileSafeMoudle/ticket/role/operationList',//操作人
    ticketGuardianList:config.baseURL+'/mobileSafeMoudle/ticket/role/operationTicketGuardianList',//监护人
    dutyCenterLeaderList:config.baseURL+'/mobileSafeMoudle/ticket/role/dutyCenterLeaderList',//指挥中心负责人列表
    dutyCenterDutyList:config.baseURL+'/mobileSafeMoudle/ticket/role/dutyCenterDutyList',//指挥中心值班人列表
    requestTicketNumber:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/requestTicketNumber',//申请操作票票号
    ticketOperationStatus:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/ticketIssuerTicketOperationStatus',//将操作票置为修改状态
    editTicketOperation:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/editTicketOperation',//修改操作票
    addTicketOperation:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/addTicketOperation',//添加操作票
    operationType:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationTypeList',//操作票类型
    operationLibrary:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationTicketOperationLibrary',//生成操作流程
    operationTasksSave:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationTicketOperationTasksSave',//添加操作流程
    operationRiskList:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationRiskPointList',//操作危险点列表
    riskControlLibrary:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationTicketRiskControlLibrary',//生成操作危险点预控卡措施
    riskControlTasks:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/createOperationTicketRiskControlTasks',//生成操作危险点预控卡
    addRiskControlTasks:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationTicketRiskControlCardSave',//添加操作危险点预控卡
    submitTicketWork:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/ticketOperationSubmit',//提交操作票
    signUpload:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/upload/signature',//操作票签名
    ticketConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/ticketOperationConfirm',//操作票审核许可人法令
    ticketReceiptOrder:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationTicketReceiptOrder',//受领人首领
    czrRiskCardConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationRiskCardConfirm',//操作人审核危险预控卡
    jhrRiskCardConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/guardianRiskCardConfirm',//监护人审核危险预控卡
    zbrRiskCardConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/dutySupervisorRiskCardConfirm',//值班人审核危险预控卡
    ticketOperationList:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/ticketOperationList',//获取操作任务列表
    operationSubmitTask:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationSubmitTask',//操作人-操作票步骤确认
    applyUnLocking:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationApplyUnLocking',//操作票-操作人申请开锁权限
    operationEndConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationEndConfirm',//终结-操作人签字确认
    guardianEndConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/guardianEndConfirm',//终结-监护人签字确认
    permitIssuerEndConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/permitIssuerEndConfirm',//终结-许可人签字确认
    workLeaderEndConfirm:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/workLeaderEndConfirm',//终结-工作负责人签字确认
    signNoClosing:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationSignNoClosing',//挂牌-禁止合闸
    unSignNoClosing:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationUnSignNoClosing',//取牌-禁止合闸
    signTagGrounded:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationSignTagGrounded',//挂牌-接地
    unSignTagGrounded:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationUnSignTagGrounded',//取牌-接地
    signWorkHere:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationSignWorkHere',//挂牌-在此工作
    unSignWorkHere:config.baseURL+'/mobileSafeMoudle/ticket/ticketOperation/operationUnSignWorkHere',//取牌-在此工作
  },

  onlineVideo:{//监控视频
    list:config.baseURL+'/index.php/index.onlineVideo/list',//监控列表
  },
  task:{//任务管理
    getList:config.baseURL+'/index.php/index.task/getList',//任务列表
  },
  mainWrite:{
    mainWrite:config.baseURL+'/index.php/index.mainWrite/mainWrite',//接线图
  },
  yk:{//在线遥控
    Yklist:config.baseURL+'/index.php/index.yk/Yklist',//遥控列表
    info:config.baseURL+'/index.php/index.yk/info',//遥控点信息
    YkUsers:config.baseURL+'/index.php/index.yk/YkUsers',//遥控人员列表
    checkUser:config.baseURL+'/index.php/index.yk/checkUser',//遥控 监护 人员验证
    getYKStatus:config.baseURL+'/index.php/index.yk/getYKStatus',//遥控状态结果
    YKOperation:config.baseURL+'/index.php/index.yk/YKOperation',//遥控 开闸 合闸
  },
  wave:{// 故障录波
    getList:config.baseURL + '/index.php/index.faultWave/list',//录波列表
    info:config.baseURL+'/index.php/index.faultWave/show',//录波详情
    catalog:config.baseURL+'/index.php/index.faultWave/catalog',//召测目录文件
    file:config.baseURL+'/index.php/index.faultWave/file',//召测录波文件
    delete:config.baseURL+'/index.php/index.faultWave/delete',//删除文件
  },
  me: { // 个人中心
    update: config.baseURL + '/mobileSafeMoudle/user/profile/update', // 更新资料 
    updatePwd:config.baseURL + '/mobileSafeMoudle/user/profile/updatePwd',//修改密码
  },
  location:{//定位
    location:config.baseURL + '/mobileSafeMoudle/location/userLocation',//定位
  },
  document:{//资产管理
    count: config.baseURL +"/document/count",//数量统计
    station3Info: config.baseURL +"/station3/info",//厂站详情
    fileList: config.baseURL +"/auxiliaryfile/list",//资料管理
    equipList: config.baseURL +"/assetEquipQuery/list",//设备台账
    collectorList: config.baseURL +"/asset/assetCollect/list",//采集台账
    carList: config.baseURL +"/asset/assetCar/list",//车辆台账
    toolList: config.baseURL +"/asset/assetTools/list",//工具管理
    spareList: config.baseURL +"/control/configure/list",//备品备件
  },
  dormitoryElectricity:{//宿舍用电
    list: config.baseURL+ "/securityControl/list",//宿舍用电列表
    runYt:config.baseURL +"/securityControl/runYt",//遥调控制接口
  },
  projectManage:{//工程管理
    list: config.baseURL + "/mobileSafeMoudle/project/manage/list",//工程列表
    counts: config.baseURL + "/mobileSafeMoudle/project/manage/counts",//数量统计
    getOverView:config.baseURL+ "/mobileSafeMoudle/project/manage/getOverView",//工程概览
    addProject: config.baseURL+ "/mobileSafeMoudle/project/manage/add",//新增加工程
    projectInfo: config.baseURL+ "/mobileSafeMoudle/project/manage/detail",//工程详情
    workInfo: config.baseURL +"/mobileSafeMoudle/project/task/detail",//工作详情
    addWork:config.baseURL+"/mobileSafeMoudle/project/task/add",//提交工作
    finishProject:config.baseURL +"/mobileSafeMoudle/project/manage/finish",//项目完工
    startProject:config.baseURL +"/mobileSafeMoudle/project/manage/start",//项目开工
    taskDates: config.baseURL +"/mobileSafeMoudle/project/task/taskDates",//时间列表
    checkTodayTask: config.baseURL +"/mobileSafeMoudle/project/task/checkTodayTask",//检查本人工作是否提交
    stations:config.baseURL +"/mobileSafeMoudle/project/manage/stations",//项目包含的厂站
  },
  meter:{
    companyList: config.baseURL + "/system/miniProgram/companyList",
    projectList: config.baseURL + "/system/miniProgram/projectList",
    rateList: config.baseURL + "/system/miniProgram/rateList",
    meterList: config.baseURL + "/system/miniProgram/meterList",
    propertyList: config.baseURL + "/system/miniProgram/propertyList",
    addMeter: config.baseURL + "/system/miniProgram/addMeter",
    userList: config.baseURL + "/system/miniProgram/userList",
    meterInfo: config.baseURL + "/system/miniProgram/meterInfo",
    reset: config.baseURL + "/system/miniProgram/reset",
    recharge: config.baseURL + "/system/miniProgram/recharge",
    refund: config.baseURL + "/system/miniProgram/refund",
  },

  $post(url, data ) {  
    var token = wx.getStorageSync('token') || 0 
    var data = { ...data}
    // 当前时间戳（毫秒）
    const timestamp = Date.now().toString();
    //随机字符串
    const nonce = generateNonce();
    const rawBody = data || {};
    const sortedBody = sortObject(rawBody);
    // 拼接签名内容
    const dataToSign = 'POST' + url.replace(config.baseURL,'') + JSON.stringify(sortedBody) + timestamp + nonce;
    console.log(dataToSign)
    // 使用 HMAC-SHA256 算法生成签名
    const signature = CryptoJS.HmacSHA256(dataToSign, SECRET_KEY).toString(CryptoJS.enc.Hex);
    return new Promise((resolve, reject) => {
      wx.request({
        url, 
        data,
        method: 'POST',
        header: {
          'dataType': "json",
          'Content-Type': 'application/json',
          'Authorization': 'Bearer ' + token,
          'X-Timestamp':timestamp,
          'X-Nonce':nonce,
          'X-Signature':signature,
        },
        success: (res) => {
          console.log(res)
          if (res.data.code==200){ 
            resolve(res.data);
          } else{ // 错误提示
            resolve(res.data);
            $.toast(res.data.msg)
          }
        },
        fail: function (res) {
          console.log(res)
          $.toast('没有网络')
        },
        complete: (t) => {
          
        },
      })
    })
  },
  $get(url, data) {
    console.log(this.url)
    var token = wx.getStorageSync('token') || 0
    // 当前时间戳（毫秒）
    const timestamp = Date.now().toString();
    //随机字符串
    const nonce = generateNonce();
    const rawBody = data || {};
    const sortedBody = sortObject(rawBody);
    // 拼接签名内容
    const dataToSign = 'GET' + url.replace(config.baseURL,'') + '{}' + timestamp + nonce;
    console.log(dataToSign)
    // 使用 HMAC-SHA256 算法生成签名
    const signature = CryptoJS.HmacSHA256(dataToSign, SECRET_KEY).toString(CryptoJS.enc.Hex);
    return new Promise((resolve, reject) => {
      wx.request({
        url: url,
        data: data,
        method: 'GET',
        header: {
          'dataType': "json",
          'Content-Type': 'application/json',
          'Authorization': 'Bearer ' + token,
          'X-Timestamp':timestamp,
          'X-Nonce':nonce,
          'X-Signature':signature,
        },
        success: (res) => {
          if (res.data.code==200){ 
            console.log(res.data)
            resolve(res.data);
          } else{ // 错误提示
            $.toast(res.data.msg)
            resolve(res.data);
            if(res.data.code==1001&&!url.includes('/mobileSafeMoudle/location/userLocation')){
              $.linkurl(`/pages/main/login/login`,'redirect')
            }
          }

          // if (!token && url.indexOf('login')==-1) {
          //   $.linkurl(`/pages/main/login/login`)
          // }
          

        },
        fail: function (res) {
          reject(res.data)
        }
      })
    })
  },
  $put(url, data) {
    var token = wx.getStorageSync('token') || 0
    // 当前时间戳（毫秒）
    const timestamp = Date.now().toString();
    //随机字符串
    const nonce = generateNonce();
    const rawBody =data || {};
    const sortedBody = sortObject(rawBody);
    // 拼接签名内容
    const dataToSign = 'PUT' + url.replace(config.baseURL,'') + JSON.stringify(sortedBody) + timestamp + nonce;
    // 使用 HMAC-SHA256 算法生成签名
    const signature = CryptoJS.HmacSHA256(dataToSign, SECRET_KEY).toString(CryptoJS.enc.Hex);
    return new Promise((resolve, reject) => {
      wx.showLoading({
        title: '加载中...',
      });
      wx.request({
        url: url,
        data: data,
        method: 'PUT',
        header: {
          'dataType': "json",
          'Content-Type': 'application/json',
          'Authorization': 'Bearer ' + token,
          'X-Timestamp':timestamp,
          'X-Nonce':nonce,
          'X-Signature':signature,
        },
        success: (res) => {
          wx.hideLoading();
          if (res.data.code==200){ 
            resolve(res.data);
            
          } else{ // 错误提示
            resolve(res.data);
            $.toast(res.data.msg)
          }

          // if (!token && url.indexOf('login')==-1) {
          //   $.linkurl(`/pages/main/login/login`)
          // }
          

        },
        fail: function (res) {
          reject(res.data)
        }
      })
    })
  },
};



